{extend name="mainadmin@layouts/base" /}
{block name="head" }
<link href="__STATIC__/main/css/stylesheets/uploadify/uploadify.min.css" rel="stylesheet"/>
<link href="__STATIC__/main/css/stylesheets/page/goods.css?v=1" rel="stylesheet"/>
<link rel="stylesheet" href="__STATIC__/js/jquery/jquery_ui/jquery-ui.css">
<script src="__STATIC__/js/jquery/jquery_ui/jquery-ui.js"></script>
<style>
    @font-face{

        　　font-family:'msyhbd';
        　　src:url('__STATIC__/share/msyhbd.ttc');

    }

    #share_img_box{
        font-family:'msyhbd';
        width:375px;height: 666px; border: 1px solid #000;
        overflow: hidden;
        position: relative;
    }
    #share_bg_img{width: 100%;}
    #share_img_box .share_qrcode{ border: 1px dashed #000;position: absolute; z-index: auto; user-select: auto;}
    #share_img_box .share_avatar{position: absolute;cursor:default;  border:1px dashed #000;position: absolute; z-index: auto; user-select: auto;}
    #share_img_box .share_nick_name{position: absolute;cursor:default; border:1px dashed #000;position: absolute;font-weight: bold;z-index: auto; user-select: auto;}
    .circle{border-radius: 50%;}
    #share_img_box .share_avatar span{
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        font-size: 12px;
        background-color: #ddd;
        overflow: hidden;
    }
</style>
{/block}
{block name="main" }

<header>
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-ellipsis-v"></i>
                <strong>设置</strong>
            </li>
        </ul>
        <div style="float:right; padding-right:10px;">
            <a class="refresh" id="refresh-toggler" href=""><i class="fa fa-refresh"></i></a>
        </div>
    </div>
</header>
<form class="form-horizontal form-validate form_vbox" id="_form" method="post" action="{:url('save')}">
    <section class="vbox">
        <section class="scrollable  wrapper w-f">
            <section class="panel panel-default ">
                <header>
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#basic" data-toggle="tab">基本配置</a>
                        </li>


                    </ul>
                </header>

                <div class="tab-content ">
                    <div class="tab-pane active" id="basic">

                        <div class="form-group m-t">
                            <label class=" control-label">是否开启：</label>
                            <div class="controls">
                                <label class="radio-inline">
                                    <input name="la_status" value="2" {$setting['la_status']==2?'checked':''} type="radio"
                                    >停用
                                </label>
                                <label class="radio-inline">
                                    <input name="la_status" value="1" {$setting['la_status']==1?'checked':''} type="radio">启用
                                </label>
                                <span class="help-inline">（停用后，将不执行团队奖励）</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="form-group">
                                <label class=" control-label">联创股东：</label>
                                <div class="col-sm-8 controls">
                                    伞下团队<input type="text" name="la_gd_daili_num" class="input-mini valid" data-rule-required="true" data-rule-ismoney="true" value="{$setting['la_gd_daili_num']}" aria-required="true" aria-invalid="false">个代理，
                                    直推<input type="text" name="la_gd_fgs_num" class="input-mini valid" data-rule-required="true" data-rule-ismoney="true" value="{$setting['la_gd_fgs_num']}" aria-required="true" aria-invalid="false">个分公司，
                                    享受团队订单每单<input type="text" name="la_gd_jd_bl" class="input-mini valid" data-rule-required="true" data-rule-ismoney="true" value="{$setting['la_gd_jd_bl']}" aria-required="true" aria-invalid="false">%见单奖，
                                </div>
                            </div>

                        <div class="form-group">
                            <label class=" control-label">分公司：</label>
                            <div class="col-sm-8 controls">
                                直推<input type="text" name="la_fgs_fwzx_num" class="input-mini valid" data-rule-required="true" data-rule-ismoney="true" value="{$setting['la_fgs_fwzx_num']}" aria-required="true" aria-invalid="false">个服务中心，
                                享受团队订单每单<input type="text" name="la_fgs_jd_bl" class="input-mini valid" data-rule-required="true" data-rule-ismoney="true" value="{$setting['la_fgs_jd_bl']}" aria-required="true" aria-invalid="false">%见单奖，
                            </div>
                        </div>
                        <div class="form-group">
                            <label class=" control-label">服务中心：</label>
                            <div class="col-sm-8 controls">
                                伞下团队<input type="text" name="la_fwzx_daili_num" class="input-mini valid" data-rule-required="true" data-rule-ismoney="true" value="{$setting['la_fwzx_daili_num']}" aria-required="true" aria-invalid="false">个订单，
                                享受团队订单每单<input type="text" name="la_fwzx_jd_bl" class="input-mini valid" data-rule-required="true" data-rule-ismoney="true" value="{$setting['la_fwzx_jd_bl']}" aria-required="true" aria-invalid="false">%见单奖，
                            </div>
                        </div>

                    </div>



                </div>      </div>

            </section>
        </section>
        <footer class="footer bg-white b-t p-t">
            <div class="form-group">
                <div class="controls  col-sm-offset-1">
                    <button type="submit" class="btn btn-primary" data-loading-text="保存中...">保存</button>
                </div>
            </div>
        </footer>
    </section>
</form>

<script type="text/javascript">
    function updateShareBg(img){
        $('#share_bg_img').attr("src",img.image.path);
    }

    $(function() {
        $('.share_img_list img').on('click',function () {
            $('#share_bg_img').attr("src",$(this).attr('src'));
        })
        //二维码处理
        $(".share_qrcode").draggable({containment:'#share_img_box',stop: function( event, ui ) {
            //console.log(ui);
            $("input[name='setting[share_qrcode_xy]']").val(ui.position.left+','+ui.position.top);
        }}).resizable({containment:'#share_img_box',stop: function( event, ui ) {
            //console.log(ui);
            $("input[name='setting[share_qrcode_width]']").val(ui.size.width);
            $(".share_qrcode").css({'height':ui.size.width+'px'});
        }})
        var share_qrcode_xy = '{$setting.share_qrcode_xy}';
        share_qrcode_xy = share_qrcode_xy.split(',');
        $(".share_qrcode").css({
                'left':share_qrcode_xy[0]+'px',
                'top':share_qrcode_xy[1]+'px',
                'width':{$setting.share_qrcode_width}+'px',
                'height':{$setting.share_qrcode_width}+'px',
        }).removeClass('hide');

        //头像处理
        $(".share_avatar").draggable({containment:'#share_img_box',stop: function( event, ui ) {
            //console.log(ui);
            $("input[name='setting[share_avatar_xy]']").val(ui.position.left+','+ui.position.top);
        }}).resizable({containment:'#share_img_box',stop: function( event, ui ) {
            //console.log(ui);
            $("input[name='setting[share_avatar_width]']").val(ui.size.width);
            $(".share_avatar").css({'height':ui.size.width+'px'});
        }});
        var share_avatar_xy = '{$setting.share_avatar_xy}';
        share_avatar_xy = share_avatar_xy.split(',');
        $(".share_avatar").css({
                'left':share_avatar_xy[0]+'px',
                'top':share_avatar_xy[1]+'px',
                'width':{$setting.share_avatar_width}+'px',
                'height':{$setting.share_avatar_width}+'px',
        }).removeClass('hide');
        $('.share_avatar_shape').click(function () {
            if ($(this).val() == 0){
                if ($(".share_avatar span").hasClass('circle')){
                    return false;
                }
                $(".share_avatar span").addClass('circle');
            }else{
                $(".share_avatar span").removeClass('circle');
            }
        })

        //呢称处理
        $(".share_nick_name").draggable({containment:'#share_img_box',stop: function( event, ui ) {
            //console.log(ui);
            $("input[name='setting[share_nick_name_xy]']").val(ui.position.left+','+ui.position.top);
        }});
        var share_nick_name_xy = '{$setting.share_nick_name_xy}';
        share_nick_name_xy = share_nick_name_xy.split(',');
        $(".share_nick_name").css({
                'left':share_nick_name_xy[0]+'px',
                'top':share_nick_name_xy[1]+'px',
                'font-size':{$setting.share_nick_name_size}+'px',
                'color':'{$setting.share_nick_name_color}',
        }).removeClass('hide');
        //监听文本框
        $("input[name='setting[share_nick_name_color]']").on('input propertychange', function() {
            $(".share_nick_name").css({'color':$(this).val()});

        });
        $("input[name='setting[share_nick_name_size]']").on('input propertychange', function() {
            $(".share_nick_name").css({'font-size':$(this).val()+'px'});

        });

    })
    var arrival_code = Math.ceil(Math.random() * 1000) + 1000;
    $('#sarrival_code_em').html(arrival_code);
    $('#evalArrival').click(function () {
        var _arrival_code = $('#arrival_code').val();
        if (_arrival_code == '') {
            _alert('请输入校验码，后再操作.', true);
            return false;
        }
        if (_arrival_code != arrival_code) {
            _alert('校验码为' + arrival_code + '，请核实输入是否正确.', true);
            return false;
        }
        _confirm('确定执行 - 手动执行结算？', function () {
            jq_ajax('{:url("evalArrival")}', '', function (res) {
                _alert(res.msg, true);
            });
        });
    })
    $('#show_share_img').click(function () {
        var obj = this;
        $(obj).html('预览图生成中..');
        var data = $('#_form').toJson();
        jq_ajax('{:url("mergeShareImg")}',data,function(){
            $(obj).html('点击预览效果');
            window.open("/upload/share_bg/test_share.jpg?"+ Math.random());
        })
    })
</script>

{/block}
{block name="footer" }
<script type="text/javascript">
    seajs.use(["dist/plupload/init.js", "dist/goods/init.js"])
</script>
{/block}
